package cn.paixu;

import java.util.Arrays;

public class SortTest {
    public static void main(String args[]){
        int[] arrays={23,45,62,12,14,15,36,34};
        int low=0;
        int hegh=arrays.length-1;
        sort(arrays,low,hegh);
        System.out.println(Arrays.toString(arrays));

    }
    private static int oneSort(int[] arrays,int low,int hegh){
        int i=low;
        int j=hegh;
        int x=arrays[i];
        while (i<j){

                while (x <arrays[j] && i<j) {
                    j--;
                }
                if(i<j) {
                    arrays[i] = arrays[j];
                 i++;
                }
                while (x > arrays[i] && i<j) {
                    i++;
                }
                if(i<j) {
                    arrays[j] = arrays[i];
                  j--;
                }
        }
        arrays[i]=x;
        return i;
    }
    private static void sort(int[] arrays,int low,int hegh){
        if(low<hegh){
            int index=oneSort(arrays,low,hegh);
            System.out.println(Arrays.toString(arrays));
            sort(arrays,low,index-1);
            sort(arrays,index+1,hegh);
        }
    }

}
